package com.jxnu.duewang.zmly.zhangHaoQi;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

/**
 * Created by lenovo on 2016/12/7.
 */

public class MyItemDecoration extends RecyclerView.ItemDecoration{
    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        Paint paint=new Paint();
        paint.setColor(Color.BLACK);
        int childercount=parent.getChildCount();
        for (int i = 0; i < childercount; i++) {
            if (i==0) {
                continue;
            }
            View childview=parent.getChildAt(i);
            float x=childview.getX();
            float y=childview.getY();
            int width=childview.getWidth();
            int height=childview.getHeight();
            c.drawLine(x, y, x + width, y, paint);
            c.drawLine(x, y, x, y + height, paint);
            c.drawLine(x + width, y, x + width, y + height, paint);
            c.drawLine(x, y + height, x + width, y + height, paint);
        }
        super.onDraw(c, parent, state);
    }
}
